class Person:
    def __init__(self,name):
        self.__name=name
    def get_name(self):
        return self.__name
    def set_name(self,name):
        self.__name=name
    def print_name(self):
        print(self.__name)
tom=Person('tom')
tom.print_name()
tom.set_name('jerry')
print(tom.get_name())
print(tom._Person__name)

class Segment:
    def length_cal(self):
        self.__length=abs(self.__end - self.__start)
    def __init__(self,start,end):
        self.__start=start
        self.__end=end
        Segment.length_cal(self)
    def get_start(self):
        return self.__start
    def get_end(self):
        return self.__end
    def get_length(self):
        return self.__length
    def set_start(self,start):
        self.__start=start
        Segment.length_cal(self)
    def set_end(self,end):
        self.__end=end
        Segment.length_cal(self)
    def show(self):
        print('start=%d,end=%d,length=%d'%(self.__start,self.__end,self.__length))
line=Segment(10,100)
line.show()
line.set_start(-10),line.set_end(10)
line.show()

class Parser:
    def __parse_word(self,word):
        if word.isdigit():
            print('digit %s'%word)
        elif word.isalpha():
            print('alpha %s'%word)
        else:
            print('symbol %s'%word)
    def parse_string(self,string):
        words=string.split()
        for word in words:
            self.__parse_word(word)
parser=Parser()
parser.parse_string('sum = sum + 100')